<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Replaces a child</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="domnode.removechild.html">DOMNode::removeChild</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="class.domnodelist.html">DOMNodeList</a></div>
 <div class="up"><a href="class.domnode.html">DOMNode</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="domnode.replacechild" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">DOMNode::replaceChild</h1>
  <p class="verinfo">(PHP 5)</p><p class="refpurpose"><span class="refname">DOMNode::replaceChild</span> &mdash; <span class="dc-title">
   Replaces a child
  </span></p>

 </div>
 <div class="refsect1 description" id="refsect1-domnode.replacechild-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type"><a href="class.domnode.html" class="type DOMNode">DOMNode</a></span> <span class="methodname"><strong>DOMNode::replaceChild</strong></span>
    ( <span class="methodparam"><span class="type"><a href="class.domnode.html" class="type DOMNode">DOMNode</a></span> <code class="parameter">$newnode</code></span>
   , <span class="methodparam"><span class="type"><a href="class.domnode.html" class="type DOMNode">DOMNode</a></span> <code class="parameter">$oldnode</code></span>
   )</div>

  <p class="para rdfs-comment">
   This function replaces the child <em><code class="parameter">oldnode</code></em> 
   with the passed new node. If the new node is already a child it 
   will not be added a second time. If the replacement succeeds the 
   old node is returned.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-domnode.replacechild-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">newnode</code></em></dt>

     <dd>

      <p class="para">
       The new node. It must be a member of the target document, i.e.
       created by one of the DOMDocument-&gt;createXXX() methods or imported in
       the document by <a href="domdocument.importnode.html" class="xref">DOMDocument::importNode</a>.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">oldnode</code></em></dt>

     <dd>

      <p class="para">
       The old node.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-domnode.replacechild-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   The old node or <strong><code>FALSE</code></strong> if an error occur.
  </p>
 </div>

 <div class="refsect1 errors" id="refsect1-domnode.replacechild-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">
   <dl>

    
     <dt>
<strong><code>DOM_NO_MODIFICATION_ALLOWED_ERR</code></strong></dt>

     <dd>

      <p class="para">
       Raised if this node is readonly or if the previous parent of the node
       being inserted is readonly.
      </p>
     </dd>

    
    
     <dt>
<strong><code>DOM_HIERARCHY_REQUEST_ERR</code></strong></dt>

     <dd>

      <p class="para">
       Raised if this node is of a type that does not allow children of the 
       type of the <em><code class="parameter">newnode</code></em> node, or if the node to 
       put in is one of this node&#039;s ancestors or this node itself.
      </p>
     </dd>

    
    
     <dt>
<strong><code>DOM_WRONG_DOCUMENT_ERR</code></strong></dt>

     <dd>

      <p class="para">
       Raised if <em><code class="parameter">newnode</code></em> was created from a different 
       document than the one that created this node.
      </p>
     </dd>

    
    
     <dt>
<strong><code>DOM_NOT_FOUND</code></strong></dt>

     <dd>

      <p class="para">
       Raised if <em><code class="parameter">oldnode</code></em> is not a child of this node.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 seealso" id="refsect1-domnode.replacechild-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="methodname"><a href="domnode.appendchild.html" class="methodname" rel="rdfs-seeAlso">DOMNode::appendChild()</a> - Adds new child at the end of the children</span></li>
    <li class="member"><span class="methodname"><a href="domnode.removechild.html" class="methodname" rel="rdfs-seeAlso">DOMNode::removeChild()</a> - Removes child from list of children</span></li>
   </ul>
  </p>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="domnode.removechild.html">DOMNode::removeChild</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="class.domnodelist.html">DOMNodeList</a></div>
 <div class="up"><a href="class.domnode.html">DOMNode</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
